package com.yugao.fintech.antelope.infra.dict.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yugao.fintech.antelope.infra.dict.mapper.DictItemMapper;
import com.yugao.fintech.antelope.infra.module.dict.model.entity.DictItem;
import com.yugao.fintech.framework.assistant.utils.CollectionUtils;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;


@Repository
public class DictItemManager extends ServiceImpl<DictItemMapper, DictItem>
        implements IService<DictItem> {

    public void deleteByDictIds(List<Long> dictIds) {
        if (CollectionUtils.isEmpty(dictIds)) {
            return;
        }
        LambdaQueryWrapper<DictItem> wrapper = Wrappers.<DictItem>lambdaQuery()
                .in(DictItem::getDictId, dictIds);
        this.remove(wrapper);
    }

    public void deleteByDictId(Long dictId) {
        if (Objects.isNull(dictId)) {
            return;
        }
        LambdaQueryWrapper<DictItem> wrapper = Wrappers.<DictItem>lambdaQuery()
                .eq(DictItem::getDictId, dictId);
        this.remove(wrapper);
    }
}
